import ComDate from './comDate'

export default function(){
    if(!this.open){
        return
    }
    let time = this.nowD
    
    // 当前时间的基本数据组成部分
    var year = time.getFullYear(time)
    var month = time.getMonth(time) + 1
    var date = time.getDate(time)
    
    let list = []

    // 添加月份
    let addList = (y, m, isNowYear) => {
        list.push({
            name: ComDate.getMothName(m, isNowYear ? y : false),
            m: ComDate.getMothList(y, m, ComDate.getStarNV(y, m, 1))
        })
    }

    new Array(2).fill('').forEach((_, i) => {
        let m = month + i 
        let y
        let isNowYear
        // 今年
        if(m <= 13){
            y = year
            isNowYear = false
        }else{
            // 明年
            m = m - 12
            y = year + 1
            isNowYear = true
        }

        addList(y, m, isNowYear)              
    })

    var splitNum = ((new Date().getDate() / 7) | 0) * 7
    let arr = list.flatMap((e) => e.m)
        .filter(e => e.timev)

    // 合并（星期调整）
    arr = [].concat(
        new Array(arr[0].star | 0).fill({timev: false, v: false}),
        arr
    )

    // 去掉前面用不到的
    arr = arr.splice(
        splitNum,
        arr.length
    )
    arr = arr.filter((e, i) => i < 4 * 7)
    list = [{
        m: arr
        ,name: 't'
    }]
    console.log(list)
    this.list = list //.reverse()
    this.nowTimeStr = `${year}/${month}/${date}`

}